package com.openbravo.pos.printer.ticket;

import java.awt.Font;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public abstract class BasicTicket
  implements PrintItem
{
  protected List<PrintItem> m_aCommands = new ArrayList();
  protected PrintItemLine pil = null;
  protected int m_iBodyHeight = 0;

  protected abstract Font getBaseFont();

  protected abstract int getFontHeight();

  protected abstract double getImageScale();

  public int getHeight()
  {
    return this.m_iBodyHeight;
  }

  public void draw(Graphics2D paramGraphics2D, int paramInt1, int paramInt2, int paramInt3)
  {
    int i = paramInt2;
    Iterator localIterator = this.m_aCommands.iterator();
    while (localIterator.hasNext())
    {
      PrintItem localPrintItem = (PrintItem)localIterator.next();
      localPrintItem.draw(paramGraphics2D, paramInt1, i, paramInt3);
      i += localPrintItem.getHeight();
    }
  }

  public List<PrintItem> getCommands()
  {
    return this.m_aCommands;
  }

  public void printImage(BufferedImage paramBufferedImage)
  {
    PrintItemImage localPrintItemImage = new PrintItemImage(paramBufferedImage, getImageScale());
    this.m_aCommands.add(localPrintItemImage);
    this.m_iBodyHeight += localPrintItemImage.getHeight();
  }

  public void printBarCode(String paramString1, String paramString2, String paramString3)
  {
    PrintItemBarcode localPrintItemBarcode = new PrintItemBarcode(paramString1, paramString2, paramString3, getImageScale());
    this.m_aCommands.add(localPrintItemBarcode);
    this.m_iBodyHeight += localPrintItemBarcode.getHeight();
  }

  public void beginLine(int paramInt)
  {
    this.pil = new PrintItemLine(paramInt, getBaseFont(), getFontHeight());
  }

  public void printText(int paramInt, String paramString)
  {
    if (this.pil != null)
      this.pil.addText(paramInt, paramString);
  }

  public void endLine()
  {
    if (this.pil != null)
    {
      this.m_aCommands.add(this.pil);
      this.m_iBodyHeight += this.pil.getHeight();
      this.pil = null;
    }
  }
}

/* Location:           D:\PowerFulPOS-2.30.2\openbravopos.jar
 * Qualified Name:     com.openbravo.pos.printer.ticket.BasicTicket
 * JD-Core Version:    0.6.0
 */